package com.xiangge.abstract1;

public class AbstractTest3 {
    public static void main(String[] args) {
        Person[] all = new Person[3];
        all[0] = new Chinese();
        all[1] = new American();
        all[2] = new Indian();
        for (int i = 0; i < all.length; i++) {
            all[i].eat();
        }
    }
}

abstract class Person{
    public abstract void eat();
}
class Chinese extends Person{
    @Override
    public void eat() {
        System.out.println("中国人用筷子吃饭");
    }
}
class American extends Person{
    @Override
    public void eat() {
        System.out.println("美国人用刀叉吃饭");
    }
}
class Indian extends Person{
    @Override
    public void eat() {
        System.out.println("印度人用手抓饭");
    }
}